const Router = require('koa-router');
const { verifyAuth } = require('../middleware/auth.middleware');
const {
  avatarHandler,
  coverHandler,
  pictureHandler,
  pictureResize,
  wallHandler,
  articlePicHandler
} = require('../middleware/file.middleware');
const {
  saveAvatarInfo,
  saveCoverInfo,
  savePictureInfo,
  saveWallInfo,
  saveArticlePicInfo
} = require('../controller/file.controller');

const fileRouter = new Router({ prefix: "/upload" });

// 上传用户头像
fileRouter.post("/avatar", verifyAuth, avatarHandler, saveAvatarInfo);
// 上传cover图片
fileRouter.post("/cover", verifyAuth, coverHandler, saveCoverInfo);
// 上传动态配图
fileRouter.post("/picture", verifyAuth, pictureHandler, pictureResize, savePictureInfo);
// 上传用户壁纸
fileRouter.post("/wall", verifyAuth, wallHandler, saveWallInfo);
// 上传文章配图
fileRouter.post("/article_pic", verifyAuth, articlePicHandler, saveArticlePicInfo);

module.exports = fileRouter;
